<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="crm.model.Purchase"%>
<%@page import="crm.control.PurchaseControl"%>
<%@page import="crm.util.ParamUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>purchase_update_do</title>
	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
			int id = Integer.parseInt(request.getParameter("id"));
			//System.out.println(id);

			Purchase purchase = new Purchase();
			purchase.setSingle_price(ParamUtil.getFloat(request,"single_price"));
			purchase.setGoods_num(ParamUtil.getInt(request,"goods_num"));
			purchase.setSum_fee(ParamUtil.getFloat(request,"sum_fee"));
			purchase.setGoods_name(ParamUtil.getString(request,"goods_name"));
			purchase.setPlace(ParamUtil.getString(request,"place"));
			purchase.setTime(ParamUtil.getString(request,"time"));
			purchase.setPerson(ParamUtil.getString(request,"person"));
			purchase.setSeller(ParamUtil.getString(request,"seller"));
			purchase.setSeller_contact(ParamUtil.getString(request,"seller_contact"));

			if (PurchaseControl.updatePurchase(purchase, id)){
		%>
		<script type="text/javascript">
if (window.confirm("修改成功！"))
	window.top.location.href = "../recepit/show_all_recepits.jsp";
	else
    window.top.location.href = "../recepit/show_all_recepits.jsp";
</script>
		<%
			} else {
		%>
		<script type="text/javascript">
if (window.confirm("修改失败！"))
	window.location.href = "purchase.jsp";
	else
    window.location.href = "purchase.jsp";
</script>
		<%
			}
		%>
	</body>
</html>